package org.lintcode_Close.Stage1_Easy_50.O1basicDataTypes;

/**
 * @Auther: qingle
 * @Date: 2024/8/16-21:33
 * @Description:
 * @version: 1.0
 */
public class S2反转一个三位整数 {

	public int reverseInteger(int number) {
		// write your code here
		// 操作数字
		int one = number / 100; // 123/100 = 1   900/100 = 9
		int two = number / 10 % 10;  // 123/10%10 = 2  900/10%10 = 0
		int three = number % (number/10); // 取余数 123%120 = 3  123%(123/10)=3
		return one + two*10 + three*100;
	}

//	public int reverseInteger(int number) {
//		// write your code here
//		// 操作字符串
//		String numberString = String.valueOf(number);
//		int len = numberString.length();
//
//		StringBuilder stringBuilder = new StringBuilder("");
//		for (int i = 0; i <= len - 1; i++) {
//			stringBuilder.append(numberString.substring(len - 1 - i, len - i));
//		}
//		return Integer.valueOf(stringBuilder.toString());
////		return Integer.parseInt(stringBuilder.toString());
//	}

	public static void main(String[] args) {
		int number = 123;
		int number1 = 900;
		System.out.println(new S2反转一个三位整数().reverseInteger(number));
		System.out.println(new S2反转一个三位整数().reverseInteger(number1));
	}
}
